import { Input, InputProps } from "antd"
import React from "react"

import { SFormItem } from "@/components/common"
import { useLocale } from "@/locales"

const CommonInput = ({
	labelId,
	placeholderId,
	fieldName,
	isHideLabel = false,
	rules = [],
	...props
}: { labelId: string; placeholderId: string; fieldName: string; isHideLabel?: boolean; rules?: [] } & InputProps) => {
	const { formatMessage } = useLocale()
	return (
		<SFormItem
			name={fieldName}
			label={isHideLabel ? "" : labelId === "noId" ? undefined : formatMessage({ id: labelId })}
			rules={rules}
		>
			<Input placeholder={formatMessage({ id: placeholderId })} {...props} />
		</SFormItem>
	)
}

export default CommonInput
